#include <bits/stdc++.h>

using namespace std;

const int N = 505;
int a[N][N];
int n, m, k, cnt;
typedef long long LL;


int main()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            scanf("%d", &a[i][j]);
            a[i][j] += a[i - 1][j];
        }



    LL res = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j++)
        {
            for (int l = 1, r = 1, sum = 0; r <= m; r++)
            {
                sum += a[j][r] - a[i - 1][r];
                while (sum > k)
                {
                    sum -= a[j][l] - a[i - 1][l];
                    l++;
                }
                res += r - l + 1;
            }
        }
    }

    cout << res << endl;
    return 0;
}